package com.qm.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.qm.pojo.Item;
import com.qm.pojo.ItemDesc;
import com.qm.service.DubboItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 @author james
 @create 2021-04-29 20:07
 */
@Controller
@RequestMapping("/items")
public class ItemContorller {

    @Reference(check = false)//启动时暂时不校验提供者
    private DubboItemService itemService;

    @RequestMapping("/{itemId}")
    public String findItemById(@PathVariable("itemId") Long itemId, Model model) {
        Item item = itemService.findItemById(itemId);
        ItemDesc itemDesc = itemService.findItemDescById(itemId);
        model.addAttribute("item",item);
        model.addAttribute("itemDesc", itemDesc);
        return "item";
    }

}
